﻿using System;
using System.Collections;
using ParticlePlayground;
using UnityEngine;
using UnityEngine.SceneManagement;

// Token: 0x020000FF RID: 255
public class PlaygroundScenes : MonoBehaviour
{
	// Token: 0x06000592 RID: 1426 RVA: 0x00022738 File Offset: 0x00020938
	public virtual IEnumerator Start()
	{
		yield return null;
		yield return null;
		yield return null;
		string text = this.productLabel;
		this.productLabel = string.Concat(new object[]
		{
			text,
			" ",
			ParticlePlayground.PlaygroundC.version,
			ParticlePlayground.PlaygroundC.specialVersion
		});
		this.sceneLabel = SceneManager.GetActiveScene().name + " Scene";
		base.InvokeRepeating("UpdateParticlesLabel", 0f, 1f);
		this.systemInfoLabel = string.Concat(new object[]
		{
			SystemInfo.deviceModel,
			"\n",
			SystemInfo.processorType,
			"\n(",
			SystemInfo.processorCount,
			" cores, ",
			SystemInfo.systemMemorySize,
			"MB RAM)\n",
			Screen.width,
			"x",
			Screen.height,
			" @",
			Screen.currentResolution.refreshRate,
			" (",
			SystemInfo.graphicsMemorySize,
			"MB VRAM)"
		});
		this.ready = true;
		yield break;
	}

	// Token: 0x06000593 RID: 1427 RVA: 0x00022754 File Offset: 0x00020954
	public virtual void Update()
	{
		if (!this.ready)
		{
			return;
		}
		if (this.showInfo)
		{
			this.frameCount++;
			this.deltaCount += Time.deltaTime;
			if (this.deltaCount > 1f / this.updateRate)
			{
				this.fps = (float)this.frameCount / this.deltaCount;
				this.frameCount = 0;
				this.deltaCount -= 1f / this.updateRate;
				if (this.fps > this.highestFps)
				{
					this.highestFps = this.fps;
				}
				if (this.fps < this.lowestFps)
				{
					this.lowestFps = this.fps;
				}
				this.fpsLabel = string.Concat(new string[]
				{
					"FPS: ",
					this.fps.ToString("f0"),
					"\nHighest: ",
					this.highestFps.ToString("f0"),
					"\nLowest: ",
					this.lowestFps.ToString("f0")
				});
			}
		}
		if ((((Input.GetMouseButtonDown(0) && this.canSwitchSceneByClick) || Input.touchCount > 0) && this.canSwitchSceneByClick) || Input.GetKeyDown(KeyCode.Return))
		{
			this.LoadNext();
		}
		if (Input.GetKey(KeyCode.Escape))
		{
			Application.Quit();
		}
	}

	// Token: 0x06000594 RID: 1428 RVA: 0x000228D0 File Offset: 0x00020AD0
	public virtual void LoadNext()
	{
		SceneManager.LoadScene((SceneManager.GetActiveScene().buildIndex + 1) % SceneManager.sceneCount);
	}

	// Token: 0x06000595 RID: 1429 RVA: 0x000228F8 File Offset: 0x00020AF8
	public virtual void OnGUI()
	{
		GUILayout.Label(this.productLabel, new GUILayoutOption[0]);
		if (this.showInfo)
		{
			GUILayout.Label(this.sceneLabel, new GUILayoutOption[0]);
			GUILayout.Label(this.contentLabel, new GUILayoutOption[0]);
			GUILayout.Label(this.totalParticlesLabel, new GUILayoutOption[0]);
			GUILayout.Label(this.systemInfoLabel, new GUILayoutOption[0]);
			GUILayout.Label(this.fpsLabel, new GUILayoutOption[0]);
			GUILayout.Label(this.timeLabel, new GUILayoutOption[0]);
		}
	}

	// Token: 0x06000596 RID: 1430 RVA: 0x00022988 File Offset: 0x00020B88
	public virtual void UpdateParticlesLabel()
	{
		this.totalParticles = 0;
		this.totalParticleSystems = 0;
		this.contentLabel = string.Empty;
		foreach (ParticlePlayground.PlaygroundParticlesC playgroundParticlesC in this.particles)
		{
			if (this.listParticleSystems)
			{
				string text = this.contentLabel;
				this.contentLabel = string.Concat(new object[]
				{
					text,
					playgroundParticlesC.particleSystemTransform.name,
					" (",
					playgroundParticlesC.particleCount,
					" ",
					this.SourceMethod(playgroundParticlesC),
					" particles)\n"
				});
			}
			this.totalParticles += playgroundParticlesC.particleCount;
			this.totalParticleSystems++;
		}
		this.totalParticlesLabel = string.Concat(new object[]
		{
			"Total ",
			this.totalParticles,
			" particles (",
			this.totalParticleSystems,
			")"
		});
		this.timeLabel = "Seconds: " + Time.timeSinceLevelLoad.ToString("f0");
	}

	// Token: 0x06000597 RID: 1431 RVA: 0x00022ABC File Offset: 0x00020CBC
	public virtual string SourceMethod(ParticlePlayground.PlaygroundParticlesC source)
	{
		string result;
		switch (source.source)
		{
		case ParticlePlayground.SOURCEC.State:
			result = "state";
			break;
		case ParticlePlayground.SOURCEC.Transform:
			result = "transform";
			break;
		case ParticlePlayground.SOURCEC.WorldObject:
			result = "mesh";
			break;
		case ParticlePlayground.SOURCEC.SkinnedWorldObject:
			result = "skinned mesh";
			break;
		case ParticlePlayground.SOURCEC.Script:
			result = ((source.eventControlledBy.Count <= 0) ? "scripted" : "event");
			break;
		case ParticlePlayground.SOURCEC.Paint:
			result = "painted";
			break;
		case ParticlePlayground.SOURCEC.Projection:
			result = "projected";
			break;
		default:
			result = string.Empty;
			break;
		}
		return result;
	}

	// Token: 0x040005AD RID: 1453
	public bool showInfo = true;

	// Token: 0x040005AE RID: 1454
	public bool listParticleSystems = true;

	// Token: 0x040005AF RID: 1455
	public bool canSwitchSceneByClick = true;

	// Token: 0x040005B0 RID: 1456
	public ParticlePlayground.PlaygroundParticlesC[] particles;

	// Token: 0x040005B1 RID: 1457
	protected string productLabel = "Particle Playground";

	// Token: 0x040005B2 RID: 1458
	protected string sceneLabel;

	// Token: 0x040005B3 RID: 1459
	protected string contentLabel;

	// Token: 0x040005B4 RID: 1460
	protected string systemInfoLabel;

	// Token: 0x040005B5 RID: 1461
	protected string fpsLabel = "wait...";

	// Token: 0x040005B6 RID: 1462
	protected string timeLabel;

	// Token: 0x040005B7 RID: 1463
	protected string totalParticlesLabel;

	// Token: 0x040005B8 RID: 1464
	protected int totalParticles;

	// Token: 0x040005B9 RID: 1465
	protected int totalParticleSystems;

	// Token: 0x040005BA RID: 1466
	protected float updateRate = 2f;

	// Token: 0x040005BB RID: 1467
	protected float fps;

	// Token: 0x040005BC RID: 1468
	protected float highestFps;

	// Token: 0x040005BD RID: 1469
	protected float lowestFps = 9999f;

	// Token: 0x040005BE RID: 1470
	protected float deltaCount;

	// Token: 0x040005BF RID: 1471
	protected int frameCount;

	// Token: 0x040005C0 RID: 1472
	protected bool ready;
}
